<template>
  <div class="welcome">
    <el-header>
      <!-- <img src="../assets/snipaste20230607_111050.jpg" alt="" /> -->
      <div class="headerright">
        <h1>电商后台管理系统</h1>
      </div>
      <el-button type="success" @click="tc">退出</el-button>
    </el-header>
    <el-container class="el-container1">
      <el-aside :width="flag ? '40px' : '200px'">
        <el-menu
          :collapse-transition="false"
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          unique-opened
          router
        >
          <div class="zhedie" @click="flag = !flag">|||</div>
          <el-submenu :index="item.path" v-for="item in list" :key="item.id">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>{{ item.authName }}</span>
            </template>
            <el-menu-item-group>
              <el-menu-item
                :index="'/' + em.path"
                v-for="em in item.children"
                :key="em.id"
              >
                <i class="el-icon-menu"></i>
                {{ em.authName }}</el-menu-item
              >
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </div>
</template>
<script>
import { huoLogin } from '@/api/user'
export default {
  name: 'WelcomeA',
  data () {
    return {
      flag: false,
      list: []
    }

  },
  created () {
    this.hq()
  },
  computed: {
  },
  methods: {
    handleOpen (key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose (key, keyPath) {
      console.log(key, keyPath);
    },
    tc () {
      this.$router.push('/login')
      this.$store.commit('user/reseToken')
    },
    async hq () {
      const res = await huoLogin()
      // console.log(res);
      this.list = res.data
      // console.log(this.list);
      console.log(this.list);
    }
  }
}
</script>
<style lang='less'  scoped>
// .welcome {
//   height: 100vh;
//   background-color: #fff;
//   .el-container {
//     height: 100%;
//   }
//   .el-header {
//     display: flex;

//     justify-content: space-between;
//     background-color: #373d41;
//     // text-align: center;
//     line-height: 100%;
//     h1 {
//       color: #fff;
//     }
//   }
// }
// .el-aside1 {
//   background-color: #373d41;
// }
.welcome {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  .el-container {
    overflow: auto;
    display: flex;
    flex: 1;
  }

  h1 {
    color: #fff;
  }
}
.el-header {
  display: flex;
  justify-content: space-between;
  background-color: #373d41;
  .el-aside {
    width: 100%;
    height: 100%;
    background-color: #333744;
    overflow: auto;
  }
}
.el-aside {
  background-color: #545c64;
}
.zhedie {
  background-color: #4a5064;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  cursor: pointer;
}
</style>
